#ifndef PROGRAMMETREE_H_
#define PROGRAMMETREE_H_

#include <memory>

#include <mythtv/mythdialogs.h>

class Metadata;
class ProgrammeList;
class ParentalLevel;

class ProgrammeTreeImp;
class ProgrammeTree : public MythThemedDialog
{
    Q_OBJECT

  public:
    ProgrammeTree(MythMainWindow *lparent, const QString &window_name,
              const QString &theme_filename, const QString &name,
              ProgrammeList *programme_list);
   ~ProgrammeTree();

    void buildProgrammeList();

    void playProgramme(Metadata *someItem);
    int programmeExitType() { return m_exit_type; }

  public slots:
    void slotDoCancel();
    void slotProgrammeGallery();
    void slotProgrammeBrowser();
    void slotViewPlot();
    void slotDoFilter();
    void slotWatchProgramme();

    void handleTreeListSelection(int node_int);
    void handleTreeListEntry(int node_int);
    void playProgramme(int node_number);
    void setParentalLevel(const ParentalLevel &which_level);

  protected:
    void keyPressEvent(QKeyEvent *e);
    bool createPopup();
    void cancelPopup();
    void doMenu(bool info);

  private:
    MythPopupBox *popup;
    bool expectingPopup;
    Metadata *curitem;
    std::auto_ptr<ParentalLevel> current_parental_level;
    bool m_db_folders;

    ProgrammeList    *m_programme_list;
    GenericTree *programme_tree_root;

    int m_exit_type;

  private:
    void jumpTo(const QString &location);
    void setExitType(int exit_type) { m_exit_type = exit_type; }
    std::auto_ptr<ProgrammeTreeImp> m_imp;
};

#endif
